home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: news.dcs.warwick.ac.uk!not-for-mail
- From: D.C.Molero@dcs.warwick.ac.uk (Daniel Castillo Molero)
- Subject: linking c with tcl
- X-Nntp-Posting-Host: cocino
- Message-ID: <1996Feb28.020725.1195@dcs.warwick.ac.uk>
- Sender: news@dcs.warwick.ac.uk (Network News)
- Organization: Department of Computer Science, Warwick University, England
- Date: Wed, 28 Feb 1996 02:07:25 GMT
-
-
- Hi,
-
- I'm trying to link a tcl application with some C code. It would be very
- helpful for me to learn how to link the tcl and c code below. The real
- application that I'm trying to link is more complex, but I think if you
- could teach me the principles behind with the code given here, I would
- be able to link my application.
-
- The tcl code given here draws a horizontal line of variable length according
- to the number of times that the right cursor arrow is pressed.
- Then, the tcl application should call the c code to calculate the mid point
- of the line, and then again the tcl should draw a perpendicular to the
- original line.
-
- I'll be extremely grateful to you for any help.
-
- ---------------------------
- canvas .c
- pack .c
-
- set x 2
- set y 2
- set i 1
- set hdist(1) 0.12345678; set hdist([expr $i+1]) 2; set hdist(3) 3.12345678
-
- proc Segment {} {
- global x y i hdist
- .c create line ${x}c ${y}c [expr $x+$hdist($i)]c ${y}c
- set x [expr $x+$hdist($i)]
- incr i
- if { $i == 4 } { set i 1 }
- }
-
- # here, I would like to include a call to the C code
- # to find the mid point of the line, and use it to draw
- # the perpendicular, for example like this:
- # .c create line ${x}c 3 ${x}c 1
-
- bind .c <Right> {Segment}
-
- focus .c
-
- --------------
- C code
-
- main() {
- x = x/2.0;
- }
- --
- * Daniel Castillo. D.C.Molero@dcs.warwick.ac.uk *
-
-
-